// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//
#pragma once

#include <set>
#include <pollux/core/plan_node.h>
#include <pollux/core/query_ctx.h>
#include <pollux/parse/i_expr.h>

namespace kumo::pollux::parse {
    /// Hold parsing options.
    struct ParseOptions {
        // Retain legacy behavior by default.
        bool parseDecimalAsDouble = true;
        bool parseIntegerAsBigint = true;

        /// SQL functions could be registered with different prefixes by the user.
        /// This parameter is the registered prefix of presto or spark functions,
        /// which helps generate the correct Pollux expression.
        std::string functionPrefix;
    };

    std::shared_ptr<const core::IExpr> parseExpr(
        const std::string &expr,
        const ParseOptions &options);

    std::pair<std::shared_ptr<const core::IExpr>, core::SortOrder> parseOrderByExpr(
        const std::string &expr);

    std::vector<std::shared_ptr<const core::IExpr> > parseMultipleExpressions(
        const std::string &expr,
        const ParseOptions &options);
} // namespace kumo::pollux::parse
